/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.awt.Color;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

/**
 *
 * @author CodeBlue
 */
public class Validator {
    // validate integer number

    public static boolean validateIntegerField(JTextField txtNumber) {
        if (!txtNumber.getText().trim().matches("[\\d]{1,3}")) {
            JOptionPane.showMessageDialog(null, "Please enter a valid number!", "Error!", JOptionPane.CLOSED_OPTION);
            txtNumber.setBackground(new Color(250, 255, 168));
            txtNumber.requestFocus();
            return false;
        }
        return true;
    }
}
